package com.example.demofreemarkermysql.controller;

import com.example.service.TbBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * <p>
 * Index
 * </p>
 *
 * @author ross zhang
 * @version 1.0
 * @since 2022/4/10 19:33
 */
@RestController
public class IndexController {
    @Autowired
    private TbBookService tbBookService;
    @GetMapping
    public ModelAndView index(ModelAndView modelAndView) {
        List<TbBook> list = this.tbBookService.list();
        modelAndView.addObject("success", "我是Freemarker页面");
        modelAndView.addObject("listBook", list);
        modelAndView.setViewName("index");
        return modelAndView;
    }
}
